package ca.starfarer.kobold.model;

import ca.starfarer.kobold.dao.DAOManager;
import ca.starfarer.kobold.dao.DataAccessException;

/**
 * @author Kevin
 */
public class Library {

    public static final String EXTENSION = "sqlitedb";  // TODO

    public static Library open(String filename) throws DataAccessException {
        return new Library(filename);
    }

    public static Library create(String filename) throws DataAccessException {
        Library library = new Library(filename);
        library.getDAOManager().initializeDB();
        return library;
    }

    private final String filename;

    private final DAOManager daoManager;

    Library(String filename) throws DataAccessException {
        assert filename != null;
        this.filename = filename;
        daoManager = DAOManager.createDAOManager(filename);
        assert daoManager != null;
    }

    public String getFilename() {
        return filename;
    }

    public DAOManager getDAOManager() {
        return daoManager;
    }
}
